﻿using System;
using System.Windows.Forms;
using DXApplicationTangche.UC.项目成果管理.service;
using DXApplicationTangche.UC.生产计划.生产批生产.service;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.流程.Service;

namespace DXApplicationTangche.UC.流程
{
    public partial class Form返修接收确认 : DevExpress.XtraEditors.XtraForm
    {
        private String barcode { get; set; }
        public Boolean isDone = false;

        public Form返修接收确认(String barcode)
        {
            InitializeComponent();
            this.barcode = barcode;
        }

        private void textBox扫描_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (String.IsNullOrEmpty(this.textBox扫描.Text))
                {
                    MessageBox.Show("无扫描信息");
                    return;
                }
                //判断扫描的工牌是否正确
                String mnemonic = 项目成果Service.get判断扫描员工码是否正确(this.textBox扫描.Text.Trim());
                if (String.IsNullOrWhiteSpace(mnemonic))
                {
                    this.textBox扫描.Clear();
                    MessageBox.Show("扫描员工码错误，请重新扫描");
                    return;
                }
                try
                {
                    String re =
                        流程Service.getCurrentNodeIdByTemplateIdAndBarcode(
                            ProcessTemplateIdConsts.REWORK_PROCESS_TEMPLATE_ID,
                            this.barcode,
                            mnemonic,
                            "返修流程接收"
                        );
                    this.isDone = true;
                    MessageBox.Show("操作完成");
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                    this.isDone = false;
                }
                this.Close();
            }
        }
    }
}